package cn.com.utt.unms.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import cn.com.utt.unms.pojo.AuthSms;

@Mapper
public interface AuthSmsMapper {

	@Select("select num from auth_sms where user_id=#{userId}")
	long countAuthSmsByUserId(@Param("userId") long userId);

	@Update("update auth_sms set num=num+#{num} where user_id=#{userId}")
	void addNum(@Param("userId") long userId, @Param("num") int num);

	@Update("update  auth_sms set num=num-1 where user_id=#{userId}")
	void subCount(@Param("userId") long userId);

	@Insert("insert into `auth_sms`(user_id,num) values(#{userId},#{num})")
	@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
	void save(AuthSms authSms);

}